In this example we'll look at creating an animation similar to the looped ball animation we created using interpolators in the previous example. We'll do this now using Java and event-based programming.

The broad strategy for this program is as follows : there is a TimeSensor which genterates time events which are fed to a Jave method. As part of the Java code we keep track of the state of the animation and so at each time event we take the appropriate next step in the animation.

It can be seen that for a simple animation like this it may be much easier to buuild the interpolator rather than do the animation through Java. This is because there is a certain regularity to the motion and the key points are few and easily precomputed.

This example consists of: